package testdatagenerator;

import java.util.Random;


public class Main {
	public static void main(String[] args){
		NodeFrame n = new NodeFrame();
		n.setVisible(true);
	}
	public static int weightedChoice(double[] weights){
		int i;
		double sum = 0;
		Random rand = new Random();
		for(i=0;i<weights.length;i++){
			sum += weights[i];
		}
		double choice = rand.nextDouble(), curr = 0;
		for(i=0;curr/sum < choice;i++){
			curr += weights[i];
		}
		return i-1;
	}
}
